﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

namespace Amoo.WebControls
{
    public partial class Browser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string diretorio = Server.MapPath("~\\UserFiles\\" + ((Code.Entity.Usuario)Session["userSite"]).idUsuario.ToString());
                string padrao = "*";

                string[] arquivos = Directory.GetFiles(diretorio, padrao);

                string strHtml = "";
                foreach (string arquivo in arquivos)
                {
                    strHtml += "<div onClick=fncOpener('/userfiles/" + ((Code.Entity.Usuario)Session["userSite"]).idUsuario.ToString() + "/" + arquivo.Substring(arquivo.LastIndexOf("\\") + 1) + "')  class='TableComunidades' style='padding:5px 5px 5px 5px; float:left; width:110px; height:110px; text-align:center;'>";
                    strHtml += "    <img src='/userfiles/" + ((Code.Entity.Usuario)Session["userSite"]).idUsuario.ToString() + "/" + arquivo.Substring(arquivo.LastIndexOf("\\") + 1) + "' width=100px height=100px/>";
                    strHtml += "</div>";
                }

                dvListaImagens.InnerHtml = strHtml;
            }
            catch (Exception ex)
            { 
            
            }
        }
    }
}
